package com.manatee.commercailapp;



import com.example.commercailapp.R;

import android.support.v7.app.ActionBarActivity;
import android.app.Activity;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.*;

import com.manatee.adnet.*;


public class MainActivity extends ActionBarActivity implements AdNetInterface{
	//private TextView txt_debug;
	
	private boolean showCommercials = true;
	
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main); //will disable
        
        AdNet an = AdNet.getInstance();
        // an.setCallback(this);
        an.setMainActivity(this);
        an.getCommercials();
        an.showCommercials();

        
        
	
        Log.i("Display commercials", "Success");

        
        
    }
    
 
    
    @Override
	public void getCommercialFailed(AdNet an) {
		// TODO diplay error message
		
	}


	@Override
	public void getCommercialSuccess(AdNet an) {
		
		Log.i("DataPrepared", "AdnetShowCommercialHelper");

		
	}


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();
        if (id == R.id.action_settings) {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }
    
//    private class getCommercials extends AsyncTask<String, String, String> {
//
//		@Override
//		protected String doInBackground(String... params) {
//			String jsonStr = "";
//			try {
//        		
//				//jsonStr = AdNet.INSTANCE.getCommercial("http://adnetwork.kristoffermads.dk/get-commercial/12/12");
//        	} catch (Exception e) {
//        		jsonStr = "Errors";
//        	}
//			//Log.i("GetJsonData", jsonStr);
//			//publishProgress(jsonStr);
//			return jsonStr;
//			
//			
//		}
//    	
//		 @Override
//		    protected void onProgressUpdate(String... progress) {
//			 
//		        String json = progress[0];
//		        Log.i("Json", json);
//		        txt_debug.setText(json);
//		    }
//		
//		
//		
//    }




	
}
